Draft
Conversation
VTK.js DataArray.getState() calls Array.from() on typed arrays, which OOMs for images >~180M voxels. Temporarily swap data arrays with empty before getState(), then inject the original TypedArrays into the state. Structured clone handles TypedArrays efficiently for worker transfer. Also surface save errors as user-visible notifications (SaveSession.vue had try/finally but no catch).
The singleton ITK-wasm worker accumulates WASM heap across readImage calls. When loading a session with a large base image (~361MB) followed by a labelmap (~180MB), the heap can exceed 2GB. Emscripten's ccall returns pointers as signed i32, so pointers >2^31 wrap negative, causing RangeError. Reset the worker before deserializing segment groups to give each labelmap read a fresh WASM heap, preventing the overflow.
Rewrite session-large-uri-base test to actually trigger the signed pointer overflow bug. Uses a ZIP-based session with a Float32 1024×1024×256 base image (1GB raw, pushes WASM heap past 2GB) and an embedded .nii.gz labelmap referenced via `path` in segmentGroups. Key changes: - ZIP session format with `path`-based labelmap triggers readImage() on the shared ITK-wasm worker (the old dataSourceId approach used cached data and never hit the bug path) - Float32 base image grows the WASM heap past 2GB so output pointers exceed 2^31 and wrap negative via Emscripten's signed i32 ccall - .nii.gz labelmap format is critical: .vti uses a separate JS reader that never touches the ITK-wasm worker - Wait for async labelmap deserialization via notification/segment-group detection (it completes after views render) Verified: fails with RangeError when resetWorker() is removed, passes when the fix is active.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #852